package com.xingchi.tornado.log.event;

import com.xingchi.tornado.log.model.dto.OperateLogDTO;
import com.xingchi.tornado.log.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 操作日志数据库记录监听器
 *
 * @author xiaoya
 * @date 2024/9/26 17:24
 */
@Component
public class DaoWebLogRecordListener implements ApplicationListener<OperateLogEvent> {

    @Autowired
    private OperateLogService operateLogService;

    @Override
    public void onApplicationEvent(OperateLogEvent event) {
        OperateLogDTO operateLogDTO = event.getOperateLogDTO();
        // 执行数据库插入
        operateLogService.insert(operateLogDTO);
    }
}
